<?php
namespace control;
/*
*辅助核算类
*/

class assistAccountClass extends adIndexClass
{
    private const page = 'assistAccount';
    private const title = '辅助核算';
    public const typeOption = ['client' => '客户', 'supplier' => '供应商', 'staff' => '员工', 'department' => '部门', 'project' => '项目', 'material' => '存货', 'cash' => '现金流'];

    /**
     * 查询表单
     *
     * @param string $workFlow
     * @return string
     */
    public function homeForm(string $workFlow): string
    {
        $noButton = '';
        //生成查询表单
        switch ($workFlow){
            case '客户':
                $clientProfile = new clientProfileClass();
                $html =$clientProfile->searchHtml();
                break;
            case '供应商':
                $supplierClass = new supplierClass();
                $html =$supplierClass->searchHtml();
                break;
            case '员工':
                $staffProfiles = new staffProfilesClass();
                $html =$staffProfiles->searchHtml();
                break;
            case '部门':
            case '存货':
                $html ='';
                $noButton = 'no';
                break;
            case '现金流':
                $cash = new cashClass();
                $html =$cash->searchHtml();
                break;
            case '项目':
                $project= new projectClass();
                $html =$project->searchHtml();
                break;
            default:
                $html='';
        }

        return $this->search($html, 'menu',otherButton: $noButton);
    }

    /*列表-查询条件*/
    public function home($workFlow = '客户')
    {
        //生成查询表单
        $data = [
            "id" => "all",
            "menu" => self::typeOption
        ];
        $data['html'] = $this->homeForm($workFlow);
        $data['pageType'] = 'list';
        return $this->tab($data);
    }

    /*客户列表-查询结果*/
    public function homeSearch()
    {
        $clientProfile = new clientProfileClass();
        return $clientProfile->homeSearch();
    }

    public function supplier()
    {
        $json['html'] = $this->homeForm('供应商');
        return json_encode($json, 320);
    }

    public function supplierSearch()
    {
        $supplierClass = new supplierClass();
        return $supplierClass->homeSearch();
    }

    public function staff()
    {
        $json['html'] = $this->homeForm('员工');
        return json_encode($json, 320);
    }

    public function staffSearch()
    {
        $staffProfiles = new staffProfilesClass();
        return $staffProfiles->homeSearch();
    }

    public function department()
    {
        $json['html'] = $this->homeForm('部门');
        return json_encode($json, 320);
    }

    public function departmentSearch()
    {

        $department = new departmentClass();
        $json['html'] = $department->homeHtml();
        return json_encode($json, 320);
    }

    public function material()
    {
        $json['html'] = $this->homeForm('存货');
        return json_encode($json, 320);
    }

    public function materialSearch()
    {
        $material = new materialClass();

        $json['html'] = $material->homeHtml();
        return json_encode($json, 320);
    }
    public function cash()
    {
        $json['html'] = $this->homeForm('现金流');
        return json_encode($json, 320);
    }

    public function cashSearch()
    {
        $cash = new cashClass();
        return $cash->homeSearch();
    }

    public function project()
    {
        $json['html'] = $this->homeForm('项目');
        return json_encode($json, 320);
    }

    public function projectSearch()
    {
        $obj = new projectClass();
        return $obj->homeSearch();
    }

}

